<template>
	<view>
		<view class="topBox">
			<view class="topBoxbg">
				<image src="../../static/usercenter/jlbg.png"></image>
			</view>
			<view class="timeselect">
				<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
					<view class="uni-input">{{date}}</view>
				</picker>
				<image class="select-icon" src="../../static/usercenter/down-icon.png"></image>
			</view>
			<view class="topstatis">
				<view class="topstatis-item">
					<view class="count">{{total}}</view>
					<view class="text">技师总数</view>
				</view>
				<view class="topstatis-item">
					<view class="count">{{workTotal}}</view>
					<view class="text">技师种类</view>
				</view>
				<view class="topstatis-item">
					<view class="count">{{totalMoney}}</view>
					<view class="text">返利金额</view>
				</view>
			</view>
		</view>
		<view class="tList" v-for="item in list">
			<view class="tList-item" @click="detail(item)">
				<view class="cell01">
					<image :src="item.user.avatar"></image>
				</view>
				<view class="cell02">
					<view class="row01">
						<text class="name">{{item.user.username}}</text>
						<text class="phone">{{item.user.mobile}}</text>
					</view>
					<view class="row02">
						<text>{{item.worktype.workname}}</text>
					</view>
				</view>
				<view class="cell03">
					<image mode="aspectFill" src="../../static/usercenter/icon_zk.png"></image>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				title: 'picker',
				array: ['中国', '美国', '巴西', '日本'],
				index: 0,
				date: currentDate,
				time: '12:01',
				total: 0,
				workTotal: 0,
				totalMoney: 0,
				list: []


			}
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		onLoad() {
			this.getBackMoney();
		},
		methods: {
			detail(item) {

				uni.navigateTo({
					url: './teamWorkList?uid=' + item.uid
				})
			},
			bindDateChange: function(e) {
				this.date = e.target.value
			},

			getBackMoney() {
				let that = this;
				let param = {
					page: 1
				};
				this.$api.backMoney(param).then(res => {

					console.info(res);
					if (res.code == 1) {
						that.total = res.data.total;
						that.workTotal = res.data.worktotal;
						that.totalMoney = res.data.money;
						that.list = res.data.list;

					} else {

					}
				})

			},

			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			}
		}
	}
</script>

<style lang="scss">
	.topBox {
		position: relative;
		height: 330rpx;

		.topBoxbg {
			width: 100%;
			height: 330rpx;
			position: absolute;
			top: 0;
			left: 0;
			z-index: 0;

			image {
				width: 100%;
				height: 330rpx;
			}
		}

		.timeselect {
			position: relative;
			z-index: 2;
			display: flex;
			padding: 25rpx 0 0 40rpx;

			picker {
				color: #ffffff;
				font-size: 32rpx;
			}

			.select-icon {
				padding-left: 20rpx;
				width: 30rpx;
				height: 30rpx;
			}
		}

		.topstatis {
			position: relative;
			z-index: 2;
			display: flex;
			padding-top: 57rpx;

			.topstatis-item {
				flex: 1;

				.count {
					text-align: center;
					font-size: 48rpx;
					color: #ffffff;
				}

				.text {
					margin-top: 16rpx;
					text-align: center;
					font-size: 28rpx;
					color: #ffffff;
				}
			}
		}
	}

	.tList {
		.tList-item {
			display: flex;
			height: 110rpx;
			padding: 40rpx 0;
			margin: 0 40rpx;
			border-bottom: 1rpx solid #EBEBEB;

			.cell01 {
				image {
					width: 110rpx;
					height: 110rpx;
					border-radius: 50%;
				}

				margin-right: 30rpx;
			}

			.cell02 {
				flex: auto;

				.row01 {
					margin-bottom: 36rpx;

					.name {
						font-size: 28rpx;
						color: #333333;
						margin-right: 30rpx;
					}

					.phone {
						font-size: 24rpx;
						color: #333333;
					}
				}

				.row02 {
					font-size: 22rpx;
					color: #666666;

					text {
						border-radius: 5rpx;
						background: #F5F5F5;
						padding: 4rpx 10rpx;
					}
				}
			}

			.cell03 {
				image {
					width: 20rpx;
					height: 30rpx;
					margin-top: 30rpx;
				}
			}
		}
	}
</style>
